import request from '@/utils/request'
import { type Result } from '@/types/result'
import { type CommentDTO, type CommentPageDTO } from '@/types/comment'

// 获取指定商品的评论列表
export function getCommentsByProductIdApi(productId: string): Promise<Result> {
  return request.get(`/comments/${productId}`)
}

// 发布评论或回复
export function addCommentApi(commentDTO: CommentDTO): Promise<Result> {
  return request.post('/comments/add', commentDTO)
}

// 获取指定产品的分页评论
export function getCommentsByPageApi(commentPageDTO: CommentPageDTO): Promise<Result> {
  return request.get('/comments/page', { params: commentPageDTO })
}
